package com.itheima.demo;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @param
 * @return
 */
public class Demo3 {
    public static void main(String[] args) throws SQLException {
        //创建数据库连接池对象
       /* DruidDataSource ds=new DruidDataSource();*/
        //配置数据库连接的四大基本特征
    /*    ds.setDriverClassName("com.mysql.jdbc.Driver");
        ds.setUrl("jdbc:mysql://47.101.183.148:3306/db1?useSSL=true&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true");
        ds.setUsername("root");
        ds.setPassword("itheima29");
        Connection connection = ds.getConnection();
        System.out.println("connection = " + connection);*/
        ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("spring3.xml");
        DataSource dataSource = ac.getBean("dataSource",DataSource.class);
        Connection connection = dataSource.getConnection();
        System.out.println("connection = " + connection);
    }
}
